package com.miniprogram.admin.controller;

import com.miniprogram.admin.utils.ShiroUtils;
import com.miniprogram.bean.po.AdminRole;
import com.miniprogram.bean.vo.admin.AdminUserVo;

import java.util.List;


public abstract class AbstractController {

    protected AdminUserVo getUser() {
        return ShiroUtils.getUserEntity();
    }

    /**
     * 判断是否为超级管理员
     */
    protected boolean isSuperAdmin() {
        AdminUserVo vo = getUser();
        List<AdminRole> adminRoleList = vo.getAdminRoleList();
        for (AdminRole role : adminRoleList) {
            if ("super_admin".equals(role.getName())) {
                return true;
            }
        }
        return false;
    }

}
